package com.zhongke.cotrun.controller;

import com.zhongke.cotrun.common.util.APIResponse;
import com.zhongke.cotrun.model.exception.MyException;
import com.zhongke.cotrun.model.resultpackage.CodeMsg;
import com.zhongke.cotrun.service.TagsService;
import com.zhongke.cotrun.shiro.sys.shiro.ShiroUtils;
import com.zhongke.cotrun.shiro.web.entity.WebUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;

@RequestMapping("/Tags")
@RestController
public class TagsController {

    @Autowired
    TagsService tagsService;

    /**
     * 点赞
     * @param tagsId
     * @return
     */
    @PostMapping("/increaseThumb")
    public APIResponse increaseThumb(BigInteger tagsId) throws MyException {

        WebUserEntity userEntity= ShiroUtils.getWebUser();//用户信息
        if(userEntity==null){
            throw new MyException(CodeMsg.USER_LOGIN_ERROR);
        }
     Integer a=   tagsService.updateTags(tagsId);
        if (a!=null) {
            return APIResponse.returnSuccess(a);
        }
        return APIResponse.returnFail(CodeMsg.UPDATE_ERROR);
    }


}
